import vue from "@vitejs/plugin-vue";
import * as path from "path";
import { defineConfig } from "vite";
import electron from "vite-plugin-electron";

// import electronRenderer from "vite-plugin-electron/renderer";
// import polyfillExports from "vite-plugin-electron/polyfill-exports";

export default defineConfig({
  build: {
    emptyOutDir: false, // 默认情况下，若 outDir 在 root 目录下，则 Vite 会在构建时清空该目录
  },
  plugins: [
    vue(),
    electron([
      {
        entry: ["electron-main/index.ts", "electron-preload/preload.ts"], // 主进程文件
      },
    ]),
    // electronRenderer(),
    // polyfillExports(),
  ],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
      "@common": path.resolve(__dirname, "./src/common"),
      "@data": path.resolve(__dirname, "./src/common/data"),
      "@model": path.resolve(__dirname, "./src/common/model"),
      "@pinias": path.resolve(__dirname, "./src/common/pinias"),
      "@utils": path.resolve(__dirname, "./src/common/utils"),
    },
  },
});
